package WinterFlower;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

/**
 * @author ZJM
 * @version 1.0
 * @since 2022-07-14 19:10:12
 */
public class UseBig {
    public static void main(String[] args) {
        double d1 = 2.0,d2 = 1.1;
        System.out.println(d1-d2);

        BigDecimal b1 = new BigDecimal("20.1225689246320055");
//        大数字 不能使用 普通的算术运算 使用方法计算

        BigDecimal b2 = new BigDecimal("2.365157851258421541648158465154554");

        BigDecimal result = b1.divide(b2,30, RoundingMode.HALF_UP );

        System.out.println(result.toString());


        BigDecimal b3 = new BigDecimal(3.14);


        BigDecimal mul0 = b1.multiply(b3);
        System.out.println(mul0);


        BigDecimal mul = b1.multiply(b3,new MathContext(30,RoundingMode.HALF_UP));
        System.out.println(mul);

        BigDecimal mul1 = b1.multiply(b3);
        mul1 = mul1.setScale(30,RoundingMode.HALF_UP);
        System.out.println(mul1);

    }
}
